/**
 * 
 */
package org.xlab.baseframework.conf;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowire;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ResourceBundleMessageSource;
import org.springframework.orm.hibernate3.HibernateTransactionManager;
import org.xlab.baseframework.dao.api.ISystemCodeDAO;
import org.xlab.baseframework.dao.api.ISystemLogDAO;
import org.xlab.baseframework.dao.api.ISystemMessageDAO;
import org.xlab.baseframework.dao.api.ISystemParameterDAO;
import org.xlab.baseframework.dao.api.ISystemWebServiceSessionDAO;
import org.xlab.baseframework.dao.impl.SystemCodeDAOImpl;
import org.xlab.baseframework.dao.impl.SystemLogDAOImpl;
import org.xlab.baseframework.dao.impl.SystemMessageDAOImpl;
import org.xlab.baseframework.dao.impl.SystemParameterDAOImpl;
import org.xlab.baseframework.dao.impl.SystemWebServiceSessionDAOImpl;

/**
 * @author MaKuBEX
 * 
 */
@Configuration
public class DaoConfiguration {
	protected @Autowired(required = true)
	SessionFactory sessionFactory;

	@Bean(autowire = Autowire.BY_NAME, name = "bpf_daoMessageSource")
	@Qualifier("bpf_daoMessageSource")
	public MessageSource bpfDaoMessageSource() {
		ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
		messageSource
				.setBasename("org/xlab/baseframework/i18n/objectNotFoundException");
		return messageSource;
	}

	@Bean(autowire = Autowire.BY_NAME, name = "bpf_systemCodeDAO")
	public ISystemCodeDAO systemCodeDAO() {
		SystemCodeDAOImpl systemCodeDAO = new SystemCodeDAOImpl();
		return systemCodeDAO;
	}

	@Bean(autowire = Autowire.BY_NAME, name = "bpf_systemLogDAO")
	public ISystemLogDAO systemLogDAO() {
		SystemLogDAOImpl systemLogDAO = new SystemLogDAOImpl();
		return systemLogDAO;
	}

	@Bean(autowire = Autowire.BY_NAME, name = "bpf_systemMessageDAO")
	public ISystemMessageDAO systemMessageDAO() {
		SystemMessageDAOImpl systemMessageDAO = new SystemMessageDAOImpl();
		return systemMessageDAO;
	}

	@Bean(autowire = Autowire.BY_NAME, name = "bpf_systemParameterDAO")
	public ISystemParameterDAO systemParameterDAO() {
		SystemParameterDAOImpl systemParameterDAO = new SystemParameterDAOImpl();
		return systemParameterDAO;
	}

	@Bean(autowire = Autowire.BY_NAME, name = "bpf_systemWSSessionDAO")
	public ISystemWebServiceSessionDAO systemWebServiceSessionDAO() {
		return new SystemWebServiceSessionDAOImpl();
	}

	@Bean(autowire = Autowire.BY_NAME, name = "transactionManager")
	public HibernateTransactionManager transactionManager() {
		return new HibernateTransactionManager();
	}
}
